package com.heima.mapper;

import com.github.pagehelper.Page;
import com.heima.dto.pagedto.OperationPageDto;
import com.heima.pojo.OperateLog;
import com.heima.vo.PageResult;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface OperateLogMapper {

    //插入日志数据
    @Insert("INSERT INTO tb_operation_recode " +
            "(oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time) " +
            "VALUES " +
            "(#{operId}, #{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{operTime})")
    void insert(OperateLog log);

    /**
     * 日志记录分页查询
     * @return
     */
    Page<OperateLog> queryOperationLog(OperationPageDto dto);

    /**
     * 批量删除用户
     * @param ids
     */
    void deleteLog(List<Integer> ids);

    /**
     * 清空日志
     */
    @Delete("delete from tb_operation_recode")
    void cleanLog();
}
